/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.psc.ejb;

import com.mycompany.psc.data.TenderType;
import com.mycompany.psc.entities.Department;
import com.mycompany.psc.entities.Projects;
import com.mycompany.psc.entities.TenderItems;
import com.mycompany.psc.entities.TenderItemsData;
import com.mycompany.psc.entities.Users;
import java.util.Date;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author A7med
 */
@Singleton
//@Startup
public class Tester {

    @PersistenceContext(name = "com.mycompany_PSC_war_1.0-SNAPSHOTPU")
    EntityManager em;

    @PostConstruct
    public void testDepts() {
        /*TenderItems t=new TenderItems();
        Projects p=em.find(Projects.class, 9);
        t.setProject(p);
        t.setAuthor("a7med2");
        t.setSubmitDate(new Date());
        t.setTitle("1st test");
        t.setType(TenderType.METAL);
        TenderItemsData td=new TenderItemsData();
        td.setLossRate(1);
        td.setNotes("notes");
        td.setParent(t);
        td.setPrice(10);
        td.setQuantity(2);
        td.setRate(1);
        td.setTitle("title");
         
       em.persist(t);
       t.getTenderItemsDataList().add(td);
       em.merge(t);
        //em.persist(td);*/
        TenderItems t=em.find(TenderItems.class, 6);
        for(TenderItemsData ti:t.getTenderItemsDataList()){
            System.err.println("data="+ti.getTitle());
        }
        
    }

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
}
